#include<stdio.h>
#include<iostream>
using namespace std;


double e(double x);
double mycos(double x);
int pw(int a);
double sq(double x, int i);



void main(void)
{
	double x,so;
	cout << "input a num"<<endl;
	cin >> x;
	so = cos(x) + e(x);
	cout << so ;
}

double e(double x)
{
	int i=1;
	double so=0,co=-1;
	while (co<1e-10)
	{
		co = sq(x,i) / pw(i);
		so = so + co;
		i++;
	}
	return so+1;
}



double mycos(double x)
{
	int i=2,j=1;
	double so=0, co=-1;
	while (co<1e-10)
	{
		co = sq(x, i) / pw(i);
		i = i + 2;
		if (j % 2 == 1)
			so = so - co;
		else
		{
			so = so + co;
		}
		j++;
	}
	
	return so + 1;
}

int pw(int a)
{
	int b=1;
	while (a)
	{
		b = b*a;
		a--;
	}
	return b;
}

double sq(double x,int i)
{
	double so=1;
	while (i > 0)
	{
		so = so*x;
		i--;
	}
	return so;
}